#include "G:\shujujiego\shujujieguo\shu\BalancedTree.h"
#include <iostream>
using namespace std;
int main(){
    BalancedTree tree;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        tree.insert(b);
    }
    cout<<tree.tree_get()->val;
}